package com.zt.english.activity.word

import android.widget.TextView
import androidx.databinding.DataBindingUtil
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator

import com.zt.english.R
import com.zt.english.adapter.WordLibVpAdapter
import com.zt.english.databinding.ActivityWordLibraryBinding
import com.zt.mvvm.viewmodel.BaseViewModel


class WordLibraryViewModel : BaseViewModel<WordLibraryRepository, ActivityWordLibraryBinding>() {
    private val mTitle = listOf("热门","大学","高中","初中","小学","留学","其他")
    val mActivity by lazy { mLifecycleOwner as WordLibraryActivity }

    override fun initView() {
        mBinding.include.title = "词库"
        //自定义标题栏背景色
        mBinding.include.background = mActivity.resources.getColor(R.color.color_app_theme)
        //设置vp2适配器
        mBinding.viewpager.adapter = WordLibVpAdapter(mTitle.size,mActivity)
        mBinding.tablayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener{
            override fun onTabReselected(tab: TabLayout.Tab?) {

            }

            override fun onTabUnselected(tab: TabLayout.Tab?) {

            }

            override fun onTabSelected(tab: TabLayout.Tab?) {

            }
        })
        //绑定tabLayout和viewPager2
        TabLayoutMediator(mBinding.tablayout,mBinding.viewpager,true,TabLayoutMediator.TabConfigurationStrategy { tab, position -> tab.setText(mTitle[position]) }).attach()
    }

    override fun initData() {

    }

}